let table_name = "worker_list_table";
let table_data_url = "/sys/user/workerList";
let number_list = "<'row'<'#mytool.col-xs-3'><'col-xs-9'>><'row'<'.col-xs-12'tr>><'row'<'#num_menu.col-xs-2'l><'col-xs-10'p>>";

function action_status() {
}

let dataManage = {
    currentItem: null,
    fuzzySearch: true,
    getQueryCondition: function (data) {
        let param = {};
        param.id = $('#worker_list_user_id').val();
        return JSON.stringify(param);
    },
};

let returnData = {
    getDate: [
        {
            className: "ellipsis",
            data: "",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        }, {
            className: "ellipsis",
            data: "name",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        },
        {
            className: "ellipsis",
            data: "img",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                if (isNotNull(row.img)) {
                    return '<img alt="" src="http://img.shengongying.cn/' + row.img + '" width="50px" height="50px">';
                }
            }
        }, {
            className: "ellipsis",
            data: "job",
            render: CONSTANT.DATA_TABLES.RENDER.ELLIPSIS,
            orderable: false,
            width: "50px"
        }, {
            className: "ellipsis",
            data: "type",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                if (row.type === 0) {
                    return '临工';
                } else if (row.type === 1) {
                    return '兼职';
                } else {
                    return '全职';
                }
            }
        }, {
            className: "ellipsis",
            data: "status",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                if (row.status === 0) {
                    return '关闭';
                }else if (row.status === 1) {
                    return '启用';
                }else {
                    return "系统关闭";
                }
            }
        }, {
            className: "ellipsis",
            data: "receiveInterviewInvite",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                if (row.receiveInterviewInvite === 0) {
                    return '否';
                }else {
                    return '是';
                }

            }
        }, {
            className: "ellipsis",
            data: "receiveAnswerInvite",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                if (row.receiveAnswerInvite === 0) {
                    return '否';
                }else {
                    return '是';
                }
            }
        },
        {
            className: "ellipsis",
            data: "",
            orderable: false,
            width: "50px",
            render: function (data, type, row, meta) {
                let button = '';
                if (row.status === 2) {
                    button += '<button class="btn btn-sm btn-danger" onclick=update_status(' + row.id + ',0)>解除下架</button>'
                } else {
                    button += '<button class="btn btn-sm btn-danger" onclick=update_status(' + row.id + ',2)>下架</button>';
                }
                return button;
            }
        }
    ]
}

function foot_info(result) {
}

function createdRow(row, data, index) {
    if (data.role) {
        $(row).addClass("info");
    }
}

function drawCallback(settings) {
}

function search_user() {
    find();
}

function fn_draw_call_back() {
}

function update_status(workerListId, type) {
    HttpUtils.post_json('/sys/user/worker/list/update/status', JSON.stringify({
        'id': workerListId,
        'status': type,
    }), function (result) {
        success_msg("更新成功", function () {
            find();
        });
    });
}